package com.qk.mapper;

import com.qk.dto.UserDto;
import com.qk.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    List<User> selectList(UserDto userDto);


    void deleteById( List <Integer> ids);

    @Insert( "insert  into user(username,password,name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time) " +
            "values (#{username} ,#{password}, #{name}, #{phone}, #{email}, #{gender}, #{status}, #{deptId}, #{roleId}, #{image}, #{remark}, #{createTime}, #{updateTime})")

    void addUser(User user);

    @Select("select id, username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time" +
            " from user where id = #{id}")
    User selectById(Integer id);


    void updateUser(User  user);

    @Select( "select * from user ")
    List<User> getAll();

    List<User> getUserByRole(String roleLabel);

    List<User> getUserByDept(Integer deptId);

    @Select("select u.* ,r.label role_lable from user u  left join role r on  u.role_id = r.id where username=#{username} ")
    User SelectByUsername(String username);
}
